package com.gc.compay.service.impl;

import com.gc.compay.mapper.OrderMapper;
import com.gc.compay.service.OrderService;
import com.gsj.common.pojo.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

/**
 * @program: clms-nine
 * @description:订单service的实现层
 * @author: 智高超
 * @create: 2021-07-23 16:58
 **/
@Service
public class OrderServiceImpl implements OrderService {
    @Resource
    OrderMapper orderMapper;

    @Override
    public R getall(String ymonth) {

        //定义一个list，map来接收
        List<Map> list = orderMapper.getall(ymonth);
        List<String> data = new ArrayList<>();//将日期转换为前台data的数据
        List<String> price = new ArrayList<>();//总金额转换为前台的price数据
        //循环遍历分别拿出key和value
        for(Map map:list){
            data.add(String.valueOf(map.get("month")));//将key放到data数组
            price.add(String.valueOf(map.get("price")));//将value放到price数组
        }
        Map chardata = new HashMap<>();
        chardata.put("data",data);
        chardata.put("price",price);//将{daya:data数组,price:price数组}
        System.out.println("chardata++++++++++++"+chardata);
        return R.ok().put("chardata",chardata);

    }
}
